package com.explore.demo.controller;


import com.explore.demo.common.ServerResponse;
import com.explore.demo.pojo.CollectRelation;
import com.explore.demo.service.CollectRelationService;
import com.explore.demo.service.impl.UserServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gaolainan
 * @since 2021-04-21
 */
@RestController
@RequestMapping("/collect_relation")
public class CollectRelationController {



    @Resource
    private CollectRelationService collectRelationService;

    @GetMapping
    @ApiOperation("查询全部的用户收藏关系")
    public ServerResponse query(){
        return collectRelationService.queryAll();
    }

    @PostMapping
    @ApiOperation("创建一个 用户收藏的招聘信息")
    public ServerResponse addOne(CollectRelation collectRelation){
        return collectRelationService.addCollectRelation(collectRelation);
    }

    @DeleteMapping
    @ApiOperation("通过职位的id 取消收藏")
    public ServerResponse deleteByRecruitId(Integer recruitId, HttpServletRequest request){
        return collectRelationService.deleteByRecruitId(recruitId, request);
    }

    @PostMapping("/{userId}")
    @ApiOperation("查询用户的收藏的所有招聘信息")
    public ServerResponse queryByUserId(@PathVariable("userId") Integer userId){
        return collectRelationService.queryAllByUserId(userId);
    }
}

